package com.bc.bczbweb.common;

import com.bc.commonentity.log.AspectLogHelper;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//import com.dianping.cat.Cat;
//import com.dianping.cat.sale.Transaction;

public class GlobalLogInteceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request,
							 HttpServletResponse response, Object handler) throws Exception {
		return AspectLogHelper.springBefore(request, handler);
	}

	@Override
	public void afterCompletion(HttpServletRequest request,
								HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		if (handler instanceof HandlerMethod) {
			if (!AuthInteceptor.needCheck(request)) {
				return;
			}
			AspectLogHelper.springAfterCompletion(request,handler,ex);
		}
	}
}
